<html>
<head><meta charset="utf-8"><title>Box&lt;dyn FnOnce&gt; doesn&#x27;t respect self alignment #68304 · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html">Box&lt;dyn FnOnce&gt; doesn&#x27;t respect self alignment #68304</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="193901417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193901417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193901417">(Apr 14 2020 at 14:02)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span></p>



<a name="193901437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193901437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193901437">(Apr 14 2020 at 14:02)</a>:</h4>
<p>oh heh</p>



<a name="193901455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193901455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193901455">(Apr 14 2020 at 14:03)</a>:</h4>
<p>let's just use this topic</p>



<a name="193901649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193901649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193901649">(Apr 14 2020 at 14:04)</a>:</h4>
<p>I'm just re-skimming the comments</p>



<a name="193901762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193901762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193901762">(Apr 14 2020 at 14:04)</a>:</h4>
<p>so I got that the issue is because ...</p>



<a name="193901777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193901777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193901777">(Apr 14 2020 at 14:04)</a>:</h4>
<p>I realize I dont' think we've 100% written out the 'new plan'</p>



<a name="193901813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193901813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193901813">(Apr 14 2020 at 14:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116266">Santiago Pastorino</span> <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/193901762" title="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/193901762">said</a>:</p>
<blockquote>
<p>so I got that the issue is because ...</p>
</blockquote>
<p>yes, let's start with that</p>



<a name="193901841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193901841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193901841">(Apr 14 2020 at 14:05)</a>:</h4>
<p><code>repr(align(256))</code> is not respected when <code>Box&lt;dyn FnOnce() ...&gt;</code> because that copies self to the stack using the default alignment of 16 instead of 256. This happens because in this case, self is an unsized local and alloca only support constant arguments, not dynamic ones.</p>



<a name="193902010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902010">(Apr 14 2020 at 14:06)</a>:</h4>
<p>that's the summary I got from the issue</p>



<a name="193902095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902095">(Apr 14 2020 at 14:06)</a>:</h4>
<p>that sounds right</p>



<a name="193902152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902152">(Apr 14 2020 at 14:07)</a>:</h4>
<p>but also, we would prefer to have a way to invoke <code>Box&lt;FnOnce&gt;</code> that doesn't copy the argument <em>at all</em></p>



<a name="193902202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902202">(Apr 14 2020 at 14:07)</a>:</h4>
<p>what can be done to alleviate that is the question, I saw you were commenting about some stuff on mir building</p>



<a name="193902222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902222">(Apr 14 2020 at 14:07)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/193902152" title="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/193902152">said</a>:</p>
<blockquote>
<p>but also, we would prefer to have a way to invoke <code>Box&lt;FnOnce&gt;</code> that doesn't copy the argument <em>at all</em></p>
</blockquote>
<p>yeah, then you won't have the problem</p>



<a name="193902312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902312">(Apr 14 2020 at 14:08)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/193902152" title="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/193902152">said</a>:</p>
<blockquote>
<p>but also, we would prefer to have a way to invoke <code>Box&lt;FnOnce&gt;</code> that doesn't copy the argument <em>at all</em></p>
</blockquote>
<p>if it's not copying the argument is it reusing it from the previous context?</p>



<a name="193902386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902386">(Apr 14 2020 at 14:09)</a>:</h4>
<p>Initially, when we were contemplating 'unsized locals', the idea was <em>only</em> to support cases where no copying is required. Then we discussed extending it to support some interesting alloca use cases, but ideally with "guaranteed optimizations" that avoid copying if you stick to certain patterns. As far as I know, those guaranteed opts do not exist.</p>



<a name="193902420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902420">(Apr 14 2020 at 14:09)</a>:</h4>
<p>Yes, the idea would be that you are passing a pointer to the place where the unsized argument exists <em>now</em></p>



<a name="193902485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902485">(Apr 14 2020 at 14:09)</a>:</h4>
<p>Which, side note, <em>does</em> raise a question that I hadn't considered that much -- I'm not sure about the "backend" part of this. ie., what I was describing were changes to MIR building</p>



<a name="193902526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902526">(Apr 14 2020 at 14:10)</a>:</h4>
<p>such that instead of generating this MIR:</p>



<a name="193902613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902613">(Apr 14 2020 at 14:10)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="n">tmp0</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">*</span><span class="n">x</span><span class="w"> </span><span class="c1">// tmp0: dyn FnOnce()</span>
<span class="nb">FnOnce</span>::<span class="n">call</span><span class="p">(</span><span class="n">tmp0</span><span class="p">,</span><span class="w"> </span><span class="p">())</span><span class="w"></span>
</pre></div>



<a name="193902629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902629">(Apr 14 2020 at 14:10)</a>:</h4>
<p>you generate MIR like</p>



<a name="193902665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902665">(Apr 14 2020 at 14:10)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="n">tmp0</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="c1">// tmp0: Box&lt;dyn FnOnce()&gt;</span>
<span class="nb">FnOnce</span>::<span class="n">call</span><span class="p">(</span><span class="o">*</span><span class="n">tmp0</span><span class="p">,</span><span class="w"> </span><span class="p">())</span><span class="w"></span>
</pre></div>



<a name="193902766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902766">(Apr 14 2020 at 14:11)</a>:</h4>
<p>I guess it's kind of "on the backend" to pass that first argument "by reference", in other words, we're passing a pointer <em>into the <code>Box</code></em> and not <em>to a temp on the stack</em></p>



<a name="193902830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193902830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193902830">(Apr 14 2020 at 14:11)</a>:</h4>
<p>hmm unsure I got the difference, wouldn't you want to pass tmp0 and then when referring to the value always dereference insing the FnOnce?</p>



<a name="193903165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193903165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193903165">(Apr 14 2020 at 14:13)</a>:</h4>
<p>This is in some sense the point -- and maybe <span class="user-mention" data-user-id="119009">@eddyb</span> can weigh in a bit here --</p>



<a name="193903224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193903224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193903224">(Apr 14 2020 at 14:13)</a>:</h4>
<p>the callee should be invoked with what is essentially a "fat pointer" to the <code>dyn FnOnce</code></p>



<a name="193903293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193903293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193903293">(Apr 14 2020 at 14:14)</a>:</h4>
<p>it doesn't have to know that whether this is found in a <code>Box</code> or what</p>



<a name="193903378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193903378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193903378">(Apr 14 2020 at 14:14)</a>:</h4>
<p>you can't change the signature of <code>FnOnce::call</code></p>



<a name="193903423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193903423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193903423">(Apr 14 2020 at 14:15)</a>:</h4>
<p>but the ABI allows copy-less passing of unsized values (or any values, really)</p>



<a name="193903445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193903445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193903445">(Apr 14 2020 at 14:15)</a>:</h4>
<p>in particular the fn in question is <code>&lt;dyn FnOnce(...) as FnOnce(...)&gt;::call</code></p>



<a name="193903449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193903449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193903449">(Apr 14 2020 at 14:15)</a>:</h4>
<p>ahh I see</p>



<a name="193903507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193903507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193903507">(Apr 14 2020 at 14:15)</a>:</h4>
<p>so I guess that, in the case of parameters with unsize type, we expect a reference to them to be passed in, right?</p>



<a name="193903520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193903520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193903520">(Apr 14 2020 at 14:15)</a>:</h4>
<p>(and perhaps other types)</p>



<a name="193903655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193903655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193903655">(Apr 14 2020 at 14:16)</a>:</h4>
<p>(since the parameter here is <code>self: dyn FnOnce(...)</code>)</p>



<a name="193903763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193903763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193903763">(Apr 14 2020 at 14:17)</a>:</h4>
<p>there is some kind of magic going on that I don't see how happens here</p>



<a name="193903895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193903895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193903895">(Apr 14 2020 at 14:18)</a>:</h4>
<p>anything other than <code>Scalar</code>/<code>Vector</code>/<code>ScalarPair</code> is just passed by reference at the <em>ABI</em> level</p>



<a name="193903951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193903951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193903951">(Apr 14 2020 at 14:18)</a>:</h4>
<p>so <code>FnOnce</code> expects a param that is <code>self: dyn FnOnce(...)</code> but with some sort of magic we pass a reference to that instead?</p>



<a name="193903961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193903961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193903961">(Apr 14 2020 at 14:18)</a>:</h4>
<p>so <code>Operand::Move(_123)</code> as a call argument will result in the argument local in the callee point to <code>_123</code> in the caller's stack frame</p>



<a name="193904034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904034">(Apr 14 2020 at 14:19)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/193903895" title="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/193903895">said</a>:</p>
<blockquote>
<p>anything other than <code>Scalar</code>/<code>Vector</code>/<code>ScalarPair</code> is just passed by reference at the <em>ABI</em> level</p>
</blockquote>
<p>ahh ok :), I guess that's the magic I wasn't seeing :)</p>



<a name="193904044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904044">(Apr 14 2020 at 14:19)</a>:</h4>
<p><code>Operand::Move(*some_box)</code> will result in the argument local in the callee  point to the heap</p>



<a name="193904127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904127">(Apr 14 2020 at 14:19)</a>:</h4>
<p>ok, makes sense</p>



<a name="193904128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904128">(Apr 14 2020 at 14:19)</a>:</h4>
<p>(again, assuming it's not a scalar/vector/scalar-pair - which can be passed "by value", in registers or on the stack)</p>



<a name="193904230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904230">(Apr 14 2020 at 14:20)</a>:</h4>
<p>yeah, so what's the code doing right now?, given what you're saying right now I guess is a scalar/vector/scalar-pair?</p>



<a name="193904308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904308">(Apr 14 2020 at 14:20)</a>:</h4>
<p><code>dyn Trait</code> is not scalar/vector/scalar-pair :P</p>



<a name="193904319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904319">(Apr 14 2020 at 14:20)</a>:</h4>
<p>since we don't know what the type is</p>



<a name="193904364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904364">(Apr 14 2020 at 14:20)</a>:</h4>
<p>yeah but what I was asking is how is then behaving like that according to what you're saying?</p>



<a name="193904411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904411">(Apr 14 2020 at 14:21)</a>:</h4>
<p>how is <em>what</em> behaving?</p>



<a name="193904486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904486">(Apr 14 2020 at 14:21)</a>:</h4>
<p>and in what way?</p>



<a name="193904512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904512">(Apr 14 2020 at 14:21)</a>:</h4>
<p>so maybe my interpretation of what you're saying is wrong ...</p>



<a name="193904533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904533">(Apr 14 2020 at 14:21)</a>:</h4>
<p>I'm saying this is what the Rust ABI <em>is</em></p>



<a name="193904537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904537">(Apr 14 2020 at 14:21)</a>:</h4>
<p>and has been for years</p>



<a name="193904615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904615">(Apr 14 2020 at 14:22)</a>:</h4>
<p>it will not require any changes</p>



<a name="193904653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904653">(Apr 14 2020 at 14:22)</a>:</h4>
<p>yeah, I'm reading you wrong probably</p>



<a name="193904683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904683">(Apr 14 2020 at 14:22)</a>:</h4>
<p>so self is being copied into the stack</p>



<a name="193904696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904696">(Apr 14 2020 at 14:22)</a>:</h4>
<p>(PS, I was distracted writing up <a href="https://github.com/rust-lang/rust/issues/68304#issuecomment-613472289" title="https://github.com/rust-lang/rust/issues/68304#issuecomment-613472289">this comment</a>, which tries to collect the proposal into a single write-up, versus diffs on older write-ups, but so far what <span class="user-mention" data-user-id="119009">@eddyb</span> is saying matches my expectations, I think)</p>



<a name="193904735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904735">(Apr 14 2020 at 14:22)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> by what and when?</p>



<a name="193904763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904763">(Apr 14 2020 at 14:22)</a>:</h4>
<p>in this case</p>



<a name="193904790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904790">(Apr 14 2020 at 14:23)</a>:</h4>
<p>the status quo or what we want to change it to?</p>



<a name="193904806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904806">(Apr 14 2020 at 14:23)</a>:</h4>
<p>the status quo</p>



<a name="193904819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904819">(Apr 14 2020 at 14:23)</a>:</h4>
<p>the status quo copies <em>in the caller</em></p>



<a name="193904832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904832">(Apr 14 2020 at 14:23)</a>:</h4>
<p>yeah</p>



<a name="193904863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904863">(Apr 14 2020 at 14:23)</a>:</h4>
<p>before passing by reference the copied local</p>



<a name="193904874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904874">(Apr 14 2020 at 14:23)</a>:</h4>
<p>in particular, in the </p>
<div class="codehilite"><pre><span></span>tmp = *x
</pre></div>


<p>line of the MIR</p>



<a name="193904959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904959">(Apr 14 2020 at 14:24)</a>:</h4>
<p>so I was interpreting that you were saying that only scalar/vector/scalar-pair are copied</p>



<a name="193904980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904980">(Apr 14 2020 at 14:24)</a>:</h4>
<p>that's what have confused me</p>



<a name="193904985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904985">(Apr 14 2020 at 14:24)</a>:</h4>
<p>I was talking about calls</p>



<a name="193904995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193904995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193904995">(Apr 14 2020 at 14:24)</a>:</h4>
<p><code>=</code> always copies</p>



<a name="193905061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905061">(Apr 14 2020 at 14:24)</a>:</h4>
<p><code>fn_once(move tmp)</code> doesn't do any more copies</p>



<a name="193905078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905078">(Apr 14 2020 at 14:24)</a>:</h4>
<p>(at least I hope it doesn't, lol)</p>



<a name="193905089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905089">(Apr 14 2020 at 14:24)</a>:</h4>
<p>it's the <code>=</code> we want to get rid of</p>



<a name="193905122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905122">(Apr 14 2020 at 14:25)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="193905314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905314">(Apr 14 2020 at 14:26)</a>:</h4>
<p>OK, <span class="user-mention" data-user-id="116266">@Santiago Pastorino</span>, so the goal is "clear-ish" now?</p>



<a name="193905348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905348">(Apr 14 2020 at 14:26)</a>:</h4>
<p>was reading the comment</p>



<a name="193905349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905349">(Apr 14 2020 at 14:26)</a>:</h4>
<p>also, does what I wrote in <a href="https://github.com/rust-lang/rust/issues/68304#issuecomment-613472289" title="https://github.com/rust-lang/rust/issues/68304#issuecomment-613472289">this comment</a> make sense to you?</p>



<a name="193905351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905351">(Apr 14 2020 at 14:26)</a>:</h4>
<p>I think so</p>



<a name="193905361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905361">(Apr 14 2020 at 14:26)</a>:</h4>
<p>let me finish reading it</p>



<a name="193905439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905439">(Apr 14 2020 at 14:27)</a>:</h4>
<p>yeah makes sense, in any case I will ask some questions</p>



<a name="193905482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905482">(Apr 14 2020 at 14:27)</a>:</h4>
<p>thanks for clarifying it</p>



<a name="193905500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905500">(Apr 14 2020 at 14:27)</a>:</h4>
<p>ok, so I was going to drop a few pointers into where I think we would modify the code</p>



<a name="193905552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905552">(Apr 14 2020 at 14:28)</a>:</h4>
<p>though you may be more familiar with it than me at this point!</p>



<a name="193905729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905729">(Apr 14 2020 at 14:29)</a>:</h4>
<p>feel free to add more information if you want, I guess I'd need to investigate a couple of things to be 100% clear about how to do certain checks</p>



<a name="193905807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905807">(Apr 14 2020 at 14:29)</a>:</h4>
<p>well so <a href="https://github.com/rust-lang/rust/blob/ba72b15666b2491415aec703a02c2364fe5e2790/src/librustc_mir_build/build/expr/into.rs#L169" title="https://github.com/rust-lang/rust/blob/ba72b15666b2491415aec703a02c2364fe5e2790/src/librustc_mir_build/build/expr/into.rs#L169">this is the main place that calls are lowered</a></p>



<a name="193905915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193905915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193905915">(Apr 14 2020 at 14:30)</a>:</h4>
<p>in particular, this loop is what <a href="https://github.com/rust-lang/rust/blob/ba72b15666b2491415aec703a02c2364fe5e2790/src/librustc_mir_build/build/expr/into.rs#L208-L211" title="https://github.com/rust-lang/rust/blob/ba72b15666b2491415aec703a02c2364fe5e2790/src/librustc_mir_build/build/expr/into.rs#L208-L211">generates the temporaries for each argument</a></p>



<a name="193906109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193906109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193906109">(Apr 14 2020 at 14:31)</a>:</h4>
<p>it's not going to be <em>trivial</em> to modify this and have the code stay "beautiful"</p>



<a name="193906182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193906182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193906182">(Apr 14 2020 at 14:32)</a>:</h4>
<p>well I guess we need some operation simiar to <code>as_local_operand</code>, like <code>as_call_temporary</code></p>



<a name="193906418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193906418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193906418">(Apr 14 2020 at 14:33)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/ba72b15666b2491415aec703a02c2364fe5e2790/src/librustc_mir_build/build/expr/as_operand.rs#L16" title="https://github.com/rust-lang/rust/blob/ba72b15666b2491415aec703a02c2364fe5e2790/src/librustc_mir_build/build/expr/as_operand.rs#L16"><code>as_local_operand</code></a> is defined there</p>



<a name="193906452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193906452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193906452">(Apr 14 2020 at 14:34)</a>:</h4>
<p>and you can see that, after some intermediate calls, it winds up <a href="https://github.com/rust-lang/rust/blob/ba72b15666b2491415aec703a02c2364fe5e2790/src/librustc_mir_build/build/expr/as_operand.rs#L61" title="https://github.com/rust-lang/rust/blob/ba72b15666b2491415aec703a02c2364fe5e2790/src/librustc_mir_build/build/expr/as_operand.rs#L61">checking the "category"</a> of the expression</p>



<a name="193906515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193906515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193906515">(Apr 14 2020 at 14:34)</a>:</h4>
<p>(in particular, it distinguishes <em>places</em> from other things)</p>



<a name="193906781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193906781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193906781">(Apr 14 2020 at 14:35)</a>:</h4>
<p>well, I guess we would want to look for <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_build/hair/enum.ExprKind.html#variant.Deref" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_build/hair/enum.ExprKind.html#variant.Deref"><code>ExprKind::Deref</code></a></p>



<a name="193960819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193960819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193960819">(Apr 14 2020 at 21:45)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span class="user-mention" data-user-id="119009">@eddyb</span> I was wondering a couple of things about this</p>



<a name="193960856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193960856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193960856">(Apr 14 2020 at 21:45)</a>:</h4>
<p>first how do I check if this is not <code>Move</code></p>



<a name="193960951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193960951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193960951">(Apr 14 2020 at 21:46)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> mentioned that maybe this should be done in expr itself, checking that expr is <code>Copy</code> and <code>Sized</code></p>



<a name="193960957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193960957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193960957">(Apr 14 2020 at 21:46)</a>:</h4>
<p>and also if it's <code>Deref</code></p>



<a name="193961001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193961001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193961001">(Apr 14 2020 at 21:47)</a>:</h4>
<p>that it <em>doesn't</em> implement <code>Copy</code>, so there's a move</p>



<a name="193961016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193961016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193961016">(Apr 14 2020 at 21:47)</a>:</h4>
<p>but I think <code>Sized</code> is enough since, for now, <code>!Sized</code> implies <code>!Copy</code> (kind of sad but w/e)</p>



<a name="193961067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193961067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193961067">(Apr 14 2020 at 21:48)</a>:</h4>
<p>as for <code>Deref</code>, it wouldn't be the trait, but rather a syntactical <code>*</code> operator in the <code>Expr</code></p>



<a name="193961140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193961140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193961140">(Apr 14 2020 at 21:49)</a>:</h4>
<p>yeah, <code>Deref</code> checking is just checking if <code>expr.kind</code> is <code>ExprKind::Deref</code></p>



<a name="193961174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193961174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193961174">(Apr 14 2020 at 21:50)</a>:</h4>
<p>saw also that <a href="https://github.com/rust-lang/rust/issues/68304#issuecomment-613691940" title="https://github.com/rust-lang/rust/issues/68304#issuecomment-613691940">@**RalfJ** commented</a></p>



<a name="193961214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193961214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193961214">(Apr 14 2020 at 21:50)</a>:</h4>
<p>in fact, if you look for how <code>Operand::Move</code> vs <code>Operand::Copy</code> is decided, you should find something like <code>is_copy_modulo_regions</code></p>



<a name="193961233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193961233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193961233">(Apr 14 2020 at 21:50)</a>:</h4>
<p>ahh nice, gonna check that out</p>



<a name="193961253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/193961253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#193961253">(Apr 14 2020 at 21:50)</a>:</h4>
<p>will do this tomorrow, it's late here already, but thanks for the tips</p>



<a name="194006927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194006927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194006927">(Apr 15 2020 at 09:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116266">Santiago Pastorino</span> <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/193961174" title="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/193961174">said</a>:</p>
<blockquote>
<p>saw also that <a href="https://github.com/rust-lang/rust/issues/68304#issuecomment-613691940" title="https://github.com/rust-lang/rust/issues/68304#issuecomment-613691940">@**RalfJ** commented</a></p>
</blockquote>
<p>sorry, I was just confused</p>



<a name="194050986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194050986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194050986">(Apr 15 2020 at 15:46)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> <span class="user-mention" data-user-id="116009">@nikomatsakis</span> <a href="https://github.com/rust-lang/rust/issues/71170" title="https://github.com/rust-lang/rust/issues/71170">#71170</a>, although it doesn't work, just opened as a WIP</p>



<a name="194051084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194051084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194051084">(Apr 15 2020 at 15:47)</a>:</h4>
<p>feedback is welcome though</p>



<a name="194055523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194055523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194055523">(Apr 15 2020 at 16:18)</a>:</h4>
<p>figured that I forgot to add the <code>*tmp</code> part</p>



<a name="194060284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194060284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194060284">(Apr 15 2020 at 16:54)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span class="user-mention" data-user-id="119009">@eddyb</span> did this and didn't work</p>



<a name="194060340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194060340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194060340">(Apr 15 2020 at 16:54)</a>:</h4>
<p>have pushed all the stuff I have, there's code duplication that I was planning to remove but didn't bother that much to do it because it's not working</p>



<a name="194060433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194060433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194060433">(Apr 15 2020 at 16:55)</a>:</h4>
<p>basically <code>expr_as_call_temporary</code> is the same as <code>expr_as_operand</code> but it just adds the <code>Deref</code> bit</p>



<a name="194354410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194354410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194354410">(Apr 16 2020 at 19:19)</a>:</h4>
<div class="codehilite"><pre><span></span>// MIR for `f2` 0 mir_map

| User Type Annotations
| 0: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }, CanonicalVarInfo { kind: Ty(General(U0)) }], value: TypeOf(DefId(5:87 ~ alloc[c245]::boxed[0]::{{impl}}[0]::new[0]), UserSubsts { substs: [^0], user_self_ty: Some(UserSelfTy { impl_def_id: DefId(5:85 ~ alloc[c245]::boxed[0]::{{impl}}[0]), self_ty: std::boxed::Box&lt;^1&gt; }) }) } at src/test/ui/fn/dyn-fn-alignment.rs:18:5: 18:13
|
fn f2(_1: u8) -&gt; std::boxed::Box&lt;dyn std::ops::FnOnce() -&gt; *const A&gt; {
    debug v =&gt; _1;                       // in scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:16:7: 16:8
    let mut _0: std::boxed::Box&lt;dyn std::ops::FnOnce() -&gt; *const A&gt;; // return place in scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:16:17: 16:46
    let mut _2: std::boxed::Box&lt;dyn std::ops::FnOnce() -&gt; *const A&gt;; // in scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:18:5: 18:28
    let _3: A;                           // in scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:17:9: 17:10
    let mut _4: u8;                      // in scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:17:17: 17:18
    let mut _5: std::boxed::Box&lt;[closure@src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27 a:A]&gt;; // in scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:18:5: 18:28
    let mut _6: [closure@src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27 a:A]; // in scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27
    scope 1 {
        debug a =&gt; _3;                   // in scope 1 at src/test/ui/fn/dyn-fn-alignment.rs:17:9: 17:10
    }

    bb0: {
        StorageLive(_2);                 // bb0[0]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:18:5: 18:28
        StorageLive(_3);                 // bb0[1]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:17:9: 17:10
        StorageLive(_4);                 // bb0[2]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:17:17: 17:18
        _4 = _1;                         // bb0[3]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:17:17: 17:18
        _3 = A { v: move _4 };           // bb0[4]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:17:13: 17:20
        StorageDead(_4);                 // bb0[5]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:17:19: 17:20
        FakeRead(ForLet, _3);            // bb0[6]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:17:9: 17:10
        StorageLive(_5);                 // bb0[7]: scope 1 at src/test/ui/fn/dyn-fn-alignment.rs:18:5: 18:28
        StorageLive(_6);                 // bb0[8]: scope 1 at src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27
        _6 = [closure@src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27] { a: move _3 }; // bb0[9]: scope 1 at src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27
                                         // closure
                                         // + def_id: DefId(0:8 ~ dyn_fn_alignment[317d]::f2[0]::{{closure}}[0])
                                         // + substs: [
                                         //     i32,
                                         //     extern &quot;rust-call&quot; fn(()) -&gt; *const A,
                                         //     (A,),
                                         // ]
        _5 = const std::boxed::Box::&lt;[closure@src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27 a:A]&gt;::new(move _6) -&gt; [return: bb2, unwind: bb1]; // bb0[10]: scope 1 at src/test/ui/fn/dyn-fn-alignment.rs:18:5: 18:28
                                         // ty::Const
                                         // + ty: fn([closure@src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27 a:A]) -&gt; std::boxed::Box&lt;[closure@src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27 a:A]&gt; {std::boxed::Box::&lt;[closure@src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27 a:A]&gt;::new}
                                         // + val: Value(Scalar(&lt;ZST&gt;))
                                         // mir::Constant
                                         // + span: src/test/ui/fn/dyn-fn-alignment.rs:18:5: 18:13
                                         // + user_ty: UserType(0)
                                         // + literal: Const { ty: fn([closure@src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27 a:A]) -&gt; std::boxed::Box&lt;[closure@src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27 a:A]&gt; {std::boxed::Box::&lt;[closure@src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27 a:A]&gt;::new}, val: Value(Scalar(&lt;ZST&gt;)) }
    }

    bb1 (cleanup): {
        resume;                          // bb1[0]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:16:1: 19:2
    }

    bb2: {
        _2 = move _5 as std::boxed::Box&lt;dyn std::ops::FnOnce() -&gt; *const A&gt; (Pointer(Unsize)); // bb2[0]: scope 1 at src/test/ui/fn/dyn-fn-alignment.rs:18:5: 18:28
        drop(_5) -&gt; [return: bb4, unwind: bb1]; // bb2[1]: scope 1 at src/test/ui/fn/dyn-fn-alignment.rs:18:27: 18:28
    }

    bb3 (cleanup): {
        drop(_5) -&gt; bb1;                 // bb3[0]: scope 1 at src/test/ui/fn/dyn-fn-alignment.rs:18:27: 18:28
    }

    bb4: {
        StorageDead(_6);                 // bb4[0]: scope 1 at src/test/ui/fn/dyn-fn-alignment.rs:18:27: 18:28
        StorageDead(_5);                 // bb4[1]: scope 1 at src/test/ui/fn/dyn-fn-alignment.rs:18:27: 18:28
        StorageDead(_3);                 // bb4[2]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:19:1: 19:2
        _0 = move _2 as std::boxed::Box&lt;dyn std::ops::FnOnce() -&gt; *const A&gt; (Pointer(Unsize)); // bb4[3]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:18:5: 18:28
        drop(_2) -&gt; [return: bb6, unwind: bb1]; // bb4[4]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:19:1: 19:2
    }

    bb5 (cleanup): {
        drop(_2) -&gt; bb1;                 // bb5[0]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:19:1: 19:2
    }

    bb6: {
        StorageDead(_2);                 // bb6[0]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:19:1: 19:2
        goto -&gt; bb7;                     // bb6[1]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:19:2: 19:2
    }

    bb7: {
        return;                          // bb7[0]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:19:2: 19:2
    }
}
</pre></div>



<a name="194356075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194356075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194356075">(Apr 16 2020 at 19:33)</a>:</h4>
<p>and ...</p>



<a name="194356127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194356127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194356127">(Apr 16 2020 at 19:34)</a>:</h4>
<div class="codehilite"><pre><span></span>// MIR for `f2::{{closure}}#0` 0 mir_map

fn f2::{{closure}}#0(_1: [closure@src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27 a:A]) -&gt; *const A {
    debug a =&gt; (_1.0: A);                // in scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:17:9: 17:10
    let mut _0: *const A;                // return place in scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:18:22: 18:22
    let mut _2: &amp;A;                      // in scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:18:22: 18:23

    bb0: {
        StorageLive(_2);                 // bb0[0]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:18:22: 18:23
        _2 = &amp;(_1.0: A);                 // bb0[1]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:18:22: 18:23
        _0 = const A::f(move _2) -&gt; [return: bb2, unwind: bb1]; // bb0[2]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:18:22: 18:27
                                         // ty::Const
                                         // + ty: for&lt;&#39;r&gt; fn(&amp;&#39;r A) -&gt; *const A {A::f}
                                         // + val: Value(Scalar(&lt;ZST&gt;))
                                         // mir::Constant
                                         // + span: src/test/ui/fn/dyn-fn-alignment.rs:18:24: 18:25
                                         // + literal: Const { ty: for&lt;&#39;r&gt; fn(&amp;&#39;r A) -&gt; *const A {A::f}, val: Value(Scalar(&lt;ZST&gt;)) }
    }

    bb1 (cleanup): {
        resume;                          // bb1[0]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:18:14: 18:27
    }

    bb2: {
        StorageDead(_2);                 // bb2[0]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:18:26: 18:27
        goto -&gt; bb3;                     // bb2[1]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:18:27: 18:27
    }

    bb3: {
        return;                          // bb3[0]: scope 0 at src/test/ui/fn/dyn-fn-alignment.rs:18:27: 18:27
    }
}
</pre></div>



<a name="194356158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194356158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194356158">(Apr 16 2020 at 19:34)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span aria-label="point up" class="emoji emoji-1f446" role="img" title="point up">:point_up:</span></p>



<a name="194357851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194357851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194357851">(Apr 16 2020 at 19:48)</a>:</h4>
<p>to be honest is not clear to me what's going on</p>



<a name="194359780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194359780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194359780">(Apr 16 2020 at 20:04)</a>:</h4>
<p>well anyway nothing is being dereferenced</p>



<a name="194359793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194359793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194359793">(Apr 16 2020 at 20:04)</a>:</h4>
<p>so ...</p>



<a name="194360440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194360440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194360440">(Apr 16 2020 at 20:08)</a>:</h4>
<p><code>expr.kind</code> is always <code>Scope</code> in my case, and once is <code>Tuple</code> for the entire executing of the test case</p>



<a name="194360480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194360480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194360480">(Apr 16 2020 at 20:09)</a>:</h4>
<p>is never <code>Deref</code></p>



<a name="194362421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194362421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194362421">(Apr 16 2020 at 20:24)</a>:</h4>
<p>the only <code>Deref</code> should be in <code>libcore</code></p>



<a name="194362432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194362432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194362432">(Apr 16 2020 at 20:24)</a>:</h4>
<p>err, <code>liballoc</code></p>



<a name="194362464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194362464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194362464">(Apr 16 2020 at 20:24)</a>:</h4>
<p>the <code>impl&lt;A&gt; FnOnce&lt;A&gt; for Box&lt;dyn FnOnce&lt;A&gt;&gt;</code></p>



<a name="194363046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363046">(Apr 16 2020 at 20:29)</a>:</h4>
<p>ohh</p>



<a name="194363066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363066">(Apr 16 2020 at 20:29)</a>:</h4>
<p>but still should be printed by debug</p>



<a name="194363123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363123">(Apr 16 2020 at 20:29)</a>:</h4>
<p>when compiling liballoc</p>



<a name="194363145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363145">(Apr 16 2020 at 20:29)</a>:</h4>
<p>not any testcases</p>



<a name="194363177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363177">(Apr 16 2020 at 20:29)</a>:</h4>
<p>right</p>



<a name="194363553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363553">(Apr 16 2020 at 20:32)</a>:</h4>
<p>so the important bit should be in <code>main</code> <a href="https://gist.github.com/spastorino/36af6c8d7a31fc325ad8fe591202f9c7" title="https://gist.github.com/spastorino/36af6c8d7a31fc325ad8fe591202f9c7">https://gist.github.com/spastorino/36af6c8d7a31fc325ad8fe591202f9c7</a></p>



<a name="194363611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363611">(Apr 16 2020 at 20:32)</a>:</h4>
<p>wait, are you testing with the example from the issue?</p>



<a name="194363657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363657">(Apr 16 2020 at 20:33)</a>:</h4>
<p>number 1 rule of staring at MIR/LLVM IR: do not use formatting :P</p>



<a name="194363666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363666">(Apr 16 2020 at 20:33)</a>:</h4>
<p>too much noise</p>



<a name="194363708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363708">(Apr 16 2020 at 20:33)</a>:</h4>
<p>but also, I don't think you'll find the deref in there</p>



<a name="194363717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363717">(Apr 16 2020 at 20:33)</a>:</h4>
<p>it's in <code>liballoc</code></p>



<a name="194363751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363751">(Apr 16 2020 at 20:33)</a>:</h4>
<p>stable code can't do it, it's gated by <code>#![feature(unsized_locals)]</code></p>



<a name="194363766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363766">(Apr 16 2020 at 20:34)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/194363611" title="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/194363611">said</a>:</p>
<blockquote>
<p>wait, are you testing with the example from the issue?</p>
</blockquote>
<p>yes</p>



<a name="194363817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363817">(Apr 16 2020 at 20:34)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/194363717" title="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/194363717">said</a>:</p>
<blockquote>
<p>it's in <code>liballoc</code></p>
</blockquote>
<p>ahh got it got it, so how can I debug this?</p>



<a name="194363833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363833">(Apr 16 2020 at 20:34)</a>:</h4>
<p>find the impl and copy it</p>



<a name="194363844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363844">(Apr 16 2020 at 20:34)</a>:</h4>
<p>:)</p>



<a name="194363868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363868">(Apr 16 2020 at 20:34)</a>:</h4>
<p>ok</p>



<a name="194363904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363904">(Apr 16 2020 at 20:35)</a>:</h4>
<p>or rather, take the method out and make it a free <code>fn</code></p>



<a name="194363913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363913">(Apr 16 2020 at 20:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/194363657" title="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/194363657">said</a>:</p>
<blockquote>
<p>number 1 rule of staring at MIR/LLVM IR: do not use formatting :P</p>
</blockquote>
<p>what do you meant?</p>



<a name="194363936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363936">(Apr 16 2020 at 20:35)</a>:</h4>
<p>don't use <code>println!</code>, <code>dbg!</code>, <code>panic!</code> etc.</p>



<a name="194363947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194363947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194363947">(Apr 16 2020 at 20:35)</a>:</h4>
<p>ok ok :)</p>



<a name="194364359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194364359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194364359">(Apr 16 2020 at 20:39)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">impl</span><span class="o">&lt;</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">F</span>: <span class="nb">FnOnce</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="o">?</span><span class="nb">Sized</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">FnOnce</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">F</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Output</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&lt;</span><span class="n">F</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nb">FnOnce</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;&gt;</span>::<span class="n">Output</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="k">extern</span><span class="w"> </span><span class="s">&quot;rust-call&quot;</span><span class="w"> </span><span class="k">fn</span> <span class="nf">call_once</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">args</span>: <span class="nc">A</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">Output</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="o">&lt;</span><span class="n">F</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nb">FnOnce</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;&gt;</span>::<span class="n">call_once</span><span class="p">(</span><span class="o">*</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">args</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="194364406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194364406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194364406">(Apr 16 2020 at 20:39)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> you meant to copy this to my test file and see the mir dump of it?</p>



<a name="194364480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194364480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194364480">(Apr 16 2020 at 20:40)</a>:</h4>
<p>but not like that, since it would be orphan</p>



<a name="194364600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194364600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194364600">(Apr 16 2020 at 20:41)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">extern</span><span class="w"> </span><span class="s">&quot;rust-call&quot;</span><span class="w"> </span><span class="k">fn</span> <span class="nf">dispatch_boxed</span><span class="o">&lt;</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">F</span>: <span class="nb">FnOnce</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="o">?</span><span class="nb">Sized</span><span class="o">&gt;</span><span class="p">(</span><span class="n">boxed</span>: <span class="nb">Box</span><span class="o">&lt;</span><span class="n">F</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">args</span>: <span class="nc">A</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">F</span>::<span class="n">Output</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">F</span>::<span class="n">call_once</span><span class="p">(</span><span class="o">*</span><span class="n">boxed</span><span class="p">,</span><span class="w"> </span><span class="n">args</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="194364611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194364611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194364611">(Apr 16 2020 at 20:41)</a>:</h4>
<p>I expect this will work</p>



<a name="194366685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194366685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194366685">(Apr 16 2020 at 20:58)</a>:</h4>
<p>I guess you want something like ...</p>



<a name="194366691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194366691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194366691">(Apr 16 2020 at 20:58)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="cp">#![feature(fn_traits)]</span><span class="w"></span>
<span class="cp">#![feature(unboxed_closures)]</span><span class="w"></span>

<span class="k">extern</span><span class="w"> </span><span class="s">&quot;rust-call&quot;</span><span class="w"> </span><span class="k">fn</span> <span class="nf">dispatch_boxed</span><span class="o">&lt;</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">F</span>: <span class="nb">FnOnce</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="o">?</span><span class="nb">Sized</span><span class="o">&gt;</span><span class="p">(</span><span class="w"></span>
<span class="w">    </span><span class="n">boxed</span>: <span class="nb">Box</span><span class="o">&lt;</span><span class="n">F</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">args</span>: <span class="nc">A</span><span class="p">,</span><span class="w"></span>
<span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">F</span>::<span class="n">Output</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">F</span>::<span class="n">call_once</span><span class="p">(</span><span class="o">*</span><span class="n">boxed</span><span class="p">,</span><span class="w"> </span><span class="n">args</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[derive(Clone, Copy)]</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">A</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">v</span>: <span class="kt">u8</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">f</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="bp">self</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="kt">usize</span><span class="w"> </span><span class="o">%</span><span class="w"> </span><span class="mi">256</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;optimized out&quot;</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">f2</span><span class="p">(</span><span class="n">v</span>: <span class="kt">u8</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Box</span><span class="o">&lt;</span><span class="n">dyn</span><span class="w"> </span><span class="nb">FnOnce</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="w">    </span><span class="n">dispatch_boxed</span><span class="p">(</span><span class="nb">Box</span>::<span class="n">new</span><span class="p">(</span><span class="o">||</span><span class="w"> </span><span class="n">a</span><span class="p">.</span><span class="n">f</span><span class="p">()),</span><span class="w"> </span><span class="n">a</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</pre></div>



<a name="194366729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194366729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194366729">(Apr 16 2020 at 20:58)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> getting compilation errors but I'm not sure what was your intention exactly</p>



<a name="194366783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194366783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194366783">(Apr 16 2020 at 20:59)</a>:</h4>
<p>like dispatch_boxed won't return a <code>Box&lt;dyn FnOnce&gt;</code> anymore</p>



<a name="194366954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194366954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194366954">(Apr 16 2020 at 21:00)</a>:</h4>
<p>maybe we want <code>-&gt; Box&lt;F::Output&gt;</code>?</p>



<a name="194367057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194367057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194367057">(Apr 16 2020 at 21:01)</a>:</h4>
<p>no, why would the return type be boxed?</p>



<a name="194367150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194367150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194367150">(Apr 16 2020 at 21:02)</a>:</h4>
<p>yeah doesn't make sense :)</p>



<a name="194367180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194367180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194367180">(Apr 16 2020 at 21:02)</a>:</h4>
<p>let me fix the example</p>



<a name="194367217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194367217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194367217">(Apr 16 2020 at 21:03)</a>:</h4>
<p>Is this it? </p>
<div class="codehilite"><pre><span></span><span class="cp">#![feature(fn_traits)]</span><span class="w"></span>
<span class="cp">#![feature(unboxed_closures)]</span><span class="w"></span>
<span class="cp">#![feature(unsized_locals)]</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">dispatch_boxed</span><span class="o">&lt;</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">F</span>: <span class="nb">FnOnce</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="o">?</span><span class="nb">Sized</span><span class="o">&gt;</span><span class="p">(</span><span class="w"></span>
<span class="w">    </span><span class="n">boxed</span>: <span class="nb">Box</span><span class="o">&lt;</span><span class="n">F</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">args</span>: <span class="nc">A</span><span class="p">,</span><span class="w"></span>
<span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">F</span>::<span class="n">Output</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">F</span>::<span class="n">call_once</span><span class="p">(</span><span class="o">*</span><span class="n">boxed</span><span class="p">,</span><span class="w"> </span><span class="n">args</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[derive(Clone, Copy)]</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">A</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">v</span>: <span class="kt">u8</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">f</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="bp">self</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="kt">usize</span><span class="w"> </span><span class="o">%</span><span class="w"> </span><span class="mi">256</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;optimized out&quot;</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">f2</span><span class="p">(</span><span class="n">v</span>: <span class="kt">u8</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Box</span><span class="o">&lt;</span><span class="n">dyn</span><span class="w"> </span><span class="nb">FnOnce</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="w">    </span><span class="nb">Box</span>::<span class="n">new</span><span class="p">(</span><span class="k">move</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="n">a</span><span class="p">.</span><span class="n">f</span><span class="p">())</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">dispatch_boxed</span><span class="p">(</span><span class="n">f2</span><span class="p">(</span><span class="mi">42</span><span class="p">),</span><span class="w"> </span><span class="p">());</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="194367237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194367237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194367237">(Apr 16 2020 at 21:03)</a>:</h4>
<p>that looks more plausible, yes</p>



<a name="194367275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194367275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194367275">(Apr 16 2020 at 21:03)</a>:</h4>
<p>basically you only want to replace the call with <code>dispatch_boxed</code></p>



<a name="194367330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194367330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194367330">(Apr 16 2020 at 21:04)</a>:</h4>
<p>also, <code>extern "rust-call"</code> is unnecessary I've just realized</p>



<a name="194367443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194367443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194367443">(Apr 16 2020 at 21:05)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="194367496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194367496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194367496">(Apr 16 2020 at 21:05)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="cp">#![feature(fn_traits)]</span><span class="w"></span>
<span class="cp">#![feature(unboxed_closures)]</span><span class="w"></span>
<span class="cp">#![feature(unsized_locals)]</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">dispatch_boxed</span><span class="o">&lt;</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">F</span>: <span class="nb">FnOnce</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="o">?</span><span class="nb">Sized</span><span class="o">&gt;</span><span class="p">(</span><span class="n">boxed</span>: <span class="nb">Box</span><span class="o">&lt;</span><span class="n">F</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">args</span>: <span class="nc">A</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">F</span>::<span class="n">Output</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">F</span>::<span class="n">call_once</span><span class="p">(</span><span class="o">*</span><span class="n">boxed</span><span class="p">,</span><span class="w"> </span><span class="n">args</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[derive(Clone, Copy)]</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">A</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">v</span>: <span class="kt">u8</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">f</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="bp">self</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="kt">usize</span><span class="w"> </span><span class="o">%</span><span class="w"> </span><span class="mi">256</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;optimized out&quot;</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">f2</span><span class="p">(</span><span class="n">v</span>: <span class="kt">u8</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Box</span><span class="o">&lt;</span><span class="n">dyn</span><span class="w"> </span><span class="nb">FnOnce</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="w">    </span><span class="nb">Box</span>::<span class="n">new</span><span class="p">(</span><span class="k">move</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="n">a</span><span class="p">.</span><span class="n">f</span><span class="p">())</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">dispatch_boxed</span><span class="p">(</span><span class="n">f2</span><span class="p">(</span><span class="mi">42</span><span class="p">),</span><span class="w"> </span><span class="p">());</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="194367561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194367561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194367561">(Apr 16 2020 at 21:06)</a>:</h4>
<p>which is basically what <span class="user-mention" data-user-id="125250">@Wesley Wiser</span> have said</p>



<a name="194367683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194367683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194367683">(Apr 16 2020 at 21:07)</a>:</h4>
<p>gonna check mir_dump of this</p>



<a name="194368065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194368065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194368065">(Apr 16 2020 at 21:11)</a>:</h4>
<div class="codehilite"><pre><span></span>// MIR for `dispatch_boxed` 0 mir_map

| User Type Annotations
| 0: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: TypeOf(DefId(2:2105 ~ core[a8ff]::ops[0]::function[0]::FnOnce[0]::call_once[0]), UserSubsts { substs: [F, ^0], user_self_ty: None }) } at test.rs:6:5: 6:17
|
fn dispatch_boxed(_1: std::boxed::Box&lt;F&gt;, _2: A) -&gt; &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::Output {
    debug boxed =&gt; _1;                   // in scope 0 at test.rs:5:45: 5:50
    debug args =&gt; _2;                    // in scope 0 at test.rs:5:60: 5:64
    let mut _0: &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::Output; // return place in scope 0 at test.rs:5:72: 5:81
    let mut _3: F;                       // in scope 0 at test.rs:6:18: 6:24
    let mut _4: A;                       // in scope 0 at test.rs:6:26: 6:30

    bb0: {
        StorageLive(_3);                 // bb0[0]: scope 0 at test.rs:6:18: 6:24
        _3 = move (*_1);                 // bb0[1]: scope 0 at test.rs:6:18: 6:24
        StorageLive(_4);                 // bb0[2]: scope 0 at test.rs:6:26: 6:30
        _4 = move _2;                    // bb0[3]: scope 0 at test.rs:6:26: 6:30
        _0 = const &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::call_once(move _3, move _4) -&gt; [return: bb2, unwind: bb6]; // bb0[4]: scope 0 at test.rs:6:5: 6:31
                                         // ty::Const
                                         // + ty: extern &quot;rust-call&quot; fn(F, A) -&gt; &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::Output {&lt;F as std::ops::FnOnce&lt;A&gt;&gt;::call_once}
                                         // + val: Value(Scalar(&lt;ZST&gt;))
                                         // mir::Constant
                                         // + span: test.rs:6:5: 6:17
                                         // + user_ty: UserType(0)
                                         // + literal: Const { ty: extern &quot;rust-call&quot; fn(F, A) -&gt; &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::Output {&lt;F as std::ops::FnOnce&lt;A&gt;&gt;::call_once}, val: Value(Scalar(&lt;ZST&gt;)) }
    }

    bb1 (cleanup): {
        resume;                          // bb1[0]: scope 0 at test.rs:5:1: 7:2
    }

    bb2: {
        StorageDead(_4);                 // bb2[0]: scope 0 at test.rs:6:30: 6:31
        StorageDead(_3);                 // bb2[1]: scope 0 at test.rs:6:30: 6:31
        drop(_2) -&gt; [return: bb7, unwind: bb3]; // bb2[2]: scope 0 at test.rs:7:1: 7:2
    }

    bb3 (cleanup): {
        drop(_1) -&gt; bb1;                 // bb3[0]: scope 0 at test.rs:7:1: 7:2
    }

    bb4 (cleanup): {
        drop(_2) -&gt; bb3;                 // bb4[0]: scope 0 at test.rs:7:1: 7:2
    }

    bb5 (cleanup): {
        drop(_3) -&gt; bb4;                 // bb5[0]: scope 0 at test.rs:6:30: 6:31
    }

    bb6 (cleanup): {
        drop(_4) -&gt; bb5;                 // bb6[0]: scope 0 at test.rs:6:30: 6:31
    }

    bb7: {
        drop(_1) -&gt; [return: bb8, unwind: bb1]; // bb7[0]: scope 0 at test.rs:7:1: 7:2
    }

    bb8: {
        goto -&gt; bb9;                     // bb8[0]: scope 0 at test.rs:7:2: 7:2
    }

    bb9: {
        return;                          // bb9[0]: scope 0 at test.rs:7:2: 7:2
    }
}
</pre></div>



<a name="194368307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194368307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194368307">(Apr 16 2020 at 21:14)</a>:</h4>
<p>yeah it's all in <code>bb0</code></p>



<a name="194368338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194368338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194368338">(Apr 16 2020 at 21:14)</a>:</h4>
<p>the move out of <code>*_1</code> into <code>_3</code> is what you want to be different</p>



<a name="194368568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194368568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194368568">(Apr 16 2020 at 21:16)</a>:</h4>
<p>yeah I ran this with debug now and I never see a <code>ExprKind::Deref</code></p>



<a name="194368591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194368591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194368591">(Apr 16 2020 at 21:17)</a>:</h4>
<p>I wonder if I'm traversing Expr in the right way</p>



<a name="194368609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194368609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194368609">(Apr 16 2020 at 21:17)</a>:</h4>
<p>there's always <code>ExprKind::Scope</code></p>



<a name="194369602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194369602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194369602">(Apr 16 2020 at 21:26)</a>:</h4>
<p>oh you might need to unpack that</p>



<a name="194369611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194369611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194369611">(Apr 16 2020 at 21:26)</a>:</h4>
<p><code>Scope</code> is <em>everywhere</em></p>



<a name="194369627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194369627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194369627">(Apr 16 2020 at 21:26)</a>:</h4>
<p>(we may want a better mechanism for that, idk)</p>



<a name="194369651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194369651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194369651">(Apr 16 2020 at 21:26)</a>:</h4>
<p>look around for code that peeks <em>inside</em> an <code>ExprKind::Scope</code></p>



<a name="194369657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194369657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194369657">(Apr 16 2020 at 21:26)</a>:</h4>
<p>there should be some already</p>



<a name="194369751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194369751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194369751">(Apr 16 2020 at 21:27)</a>:</h4>
<p>yeah, as_operand does recursive</p>



<a name="194369808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194369808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194369808">(Apr 16 2020 at 21:28)</a>:</h4>
<p>I was also trying that before with no success but now at least I can debug it :)</p>



<a name="194369836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194369836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194369836">(Apr 16 2020 at 21:28)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="w">        </span><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="n">ExprKind</span>::<span class="n">Scope</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">region_scope</span><span class="p">,</span><span class="w"> </span><span class="n">lint_level</span><span class="p">,</span><span class="w"> </span><span class="n">value</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">expr</span><span class="p">.</span><span class="n">kind</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="kd">let</span><span class="w"> </span><span class="n">source_info</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">this</span><span class="p">.</span><span class="n">source_info</span><span class="p">(</span><span class="n">expr</span><span class="p">.</span><span class="n">span</span><span class="p">);</span><span class="w"></span>
<span class="w">            </span><span class="kd">let</span><span class="w"> </span><span class="n">region_scope</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">region_scope</span><span class="p">,</span><span class="w"> </span><span class="n">source_info</span><span class="p">);</span><span class="w"></span>
<span class="w">            </span><span class="k">return</span><span class="w"> </span><span class="n">this</span><span class="w"></span>
<span class="w">                </span><span class="p">.</span><span class="n">in_scope</span><span class="p">(</span><span class="n">region_scope</span><span class="p">,</span><span class="w"> </span><span class="n">lint_level</span><span class="p">,</span><span class="w"> </span><span class="o">|</span><span class="n">this</span><span class="o">|</span><span class="w"> </span><span class="n">this</span><span class="p">.</span><span class="n">as_operand</span><span class="p">(</span><span class="n">block</span><span class="p">,</span><span class="w"> </span><span class="n">scope</span><span class="p">,</span><span class="w"> </span><span class="n">value</span><span class="p">));</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="194370108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194370108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194370108">(Apr 16 2020 at 21:31)</a>:</h4>
<p>not <code>as_operand</code>, but something that <em>peeks</em></p>



<a name="194370113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194370113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194370113">(Apr 16 2020 at 21:31)</a>:</h4>
<p><code>as_operand</code> processes</p>



<a name="194370124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194370124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194370124">(Apr 16 2020 at 21:31)</a>:</h4>
<p>lemme look</p>



<a name="194370210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194370210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194370210">(Apr 16 2020 at 21:32)</a>:</h4>
<p>so I meant to do recursive</p>



<a name="194370226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194370226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194370226">(Apr 16 2020 at 21:32)</a>:</h4>
<p>this is what I've added ...</p>



<a name="194370234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194370234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194370234">(Apr 16 2020 at 21:32)</a>:</h4>
<div class="codehilite"><pre><span></span>        if let ExprKind::Scope { region_scope, lint_level, value } = expr.kind {
            let source_info = self.source_info(expr.span);
            let region_scope = (region_scope, source_info);
            return self
                .in_scope(region_scope, lint_level, |this| this.as_call_temporary(block, value));
        }
</pre></div>



<a name="194370256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194370256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194370256">(Apr 16 2020 at 21:32)</a>:</h4>
<p>I'm not sure recursive is correct</p>



<a name="194370285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194370285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194370285">(Apr 16 2020 at 21:33)</a>:</h4>
<p>hmpf</p>



<a name="194370294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194370294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194370294">(Apr 16 2020 at 21:33)</a>:</h4>
<p>I could totally match Scope and value of kind Deref in that case</p>



<a name="194370295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194370295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194370295">(Apr 16 2020 at 21:33)</a>:</h4>
<p>you might have to, I guess. I'll let <span class="user-mention" data-user-id="116009">@nikomatsakis</span> decide what's correct</p>



<a name="194370308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194370308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194370308">(Apr 16 2020 at 21:33)</a>:</h4>
<p>I can't find the peeking I was thinking of</p>



<a name="194370317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194370317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194370317">(Apr 16 2020 at 21:33)</a>:</h4>
<p>with recursion I get</p>



<a name="194370328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194370328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194370328">(Apr 16 2020 at 21:33)</a>:</h4>
<div class="codehilite"><pre><span></span>// MIR for `dispatch_boxed` 0 mir_map

| User Type Annotations
| 0: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: TypeOf(DefId(2:2105 ~ core[a8ff]::ops[0]::function[0]::FnOnce[0]::call_once[0]), UserSubsts { substs: [F, ^0], user_self_ty: None }) } at test.rs:6:5: 6:17
|
fn dispatch_boxed(_1: std::boxed::Box&lt;F&gt;, _2: A) -&gt; &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::Output {
    debug boxed =&gt; _1;                   // in scope 0 at test.rs:5:45: 5:50
    debug args =&gt; _2;                    // in scope 0 at test.rs:5:60: 5:64
    let mut _0: &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::Output; // return place in scope 0 at test.rs:5:72: 5:81
    let mut _3: F;                       // in scope 0 at test.rs:6:18: 6:24
    let mut _4: A;                       // in scope 0 at test.rs:6:26: 6:30

    bb0: {
        StorageLive(_3);                 // bb0[0]: scope 0 at test.rs:6:18: 6:24
        _3 = move (*_1);                 // bb0[1]: scope 0 at test.rs:6:18: 6:24
        drop(_3) -&gt; [return: bb5, unwind: bb3]; // bb0[2]: scope 0 at test.rs:6:23: 6:24
    }

    bb1 (cleanup): {
        resume;                          // bb1[0]: scope 0 at test.rs:5:1: 7:2
    }

    bb2 (cleanup): {
        drop(_1) -&gt; bb1;                 // bb2[0]: scope 0 at test.rs:7:1: 7:2
    }

    bb3 (cleanup): {
        drop(_2) -&gt; bb2;                 // bb3[0]: scope 0 at test.rs:7:1: 7:2
    }

    bb4 (cleanup): {
        drop(_3) -&gt; bb3;                 // bb4[0]: scope 0 at test.rs:6:23: 6:24
    }

    bb5: {
        StorageDead(_3);                 // bb5[0]: scope 0 at test.rs:6:23: 6:24
        StorageLive(_4);                 // bb5[1]: scope 0 at test.rs:6:26: 6:30
        _4 = move _2;                    // bb5[2]: scope 0 at test.rs:6:26: 6:30
        drop(_4) -&gt; [return: bb7, unwind: bb3]; // bb5[3]: scope 0 at test.rs:6:29: 6:30
    }

    bb6 (cleanup): {
        drop(_4) -&gt; bb3;                 // bb6[0]: scope 0 at test.rs:6:29: 6:30
    }

    bb7: {
        StorageDead(_4);                 // bb7[0]: scope 0 at test.rs:6:29: 6:30
        _0 = const &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::call_once(move _3, move _4) -&gt; [return: bb8, unwind: bb3]; // bb7[1]: scope 0 at test.rs:6:5: 6:31
                                         // ty::Const
                                         // + ty: extern &quot;rust-call&quot; fn(F, A) -&gt; &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::Output {&lt;F as std::ops::FnOnce&lt;A&gt;&gt;::call_once}
                                         // + val: Value(Scalar(&lt;ZST&gt;))
                                         // mir::Constant
                                         // + span: test.rs:6:5: 6:17
                                         // + user_ty: UserType(0)
                                         // + literal: Const { ty: extern &quot;rust-call&quot; fn(F, A) -&gt; &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::Output {&lt;F as std::ops::FnOnce&lt;A&gt;&gt;::call_once}, val: Value(Scalar(&lt;ZST&gt;)) }
    }

    bb8: {
        drop(_2) -&gt; [return: bb9, unwind: bb2]; // bb8[0]: scope 0 at test.rs:7:1: 7:2
    }

    bb9: {
        drop(_1) -&gt; [return: bb10, unwind: bb1]; // bb9[0]: scope 0 at test.rs:7:1: 7:2
    }

    bb10: {
        goto -&gt; bb11;                    // bb10[0]: scope 0 at test.rs:7:2: 7:2
    }

    bb11: {
        return;                          // bb11[0]: scope 0 at test.rs:7:2: 7:2
    }
}
</pre></div>



<a name="194370391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194370391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194370391">(Apr 16 2020 at 21:34)</a>:</h4>
<p>still not ok</p>



<a name="194376334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194376334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194376334">(Apr 16 2020 at 22:34)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> <span class="user-mention" data-user-id="125250">@Wesley Wiser</span> ...</p>



<a name="194376339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194376339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194376339">(Apr 16 2020 at 22:34)</a>:</h4>
<div class="codehilite"><pre><span></span>// MIR for `dispatch_boxed` 0 mir_map

| User Type Annotations
| 0: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: TypeOf(DefId(2:2105 ~ core[a8ff]::ops[0]::function[0]::FnOnce[0]::call_once[0]), UserSubsts { substs: [F, ^0], user_self_ty: None }) } at test.rs:6:5: 6:17
|
fn dispatch_boxed(_1: std::boxed::Box&lt;F&gt;, _2: A) -&gt; &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::Output {
    debug boxed =&gt; _1;                   // in scope 0 at test.rs:5:45: 5:50
    debug args =&gt; _2;                    // in scope 0 at test.rs:5:60: 5:64
    let mut _0: &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::Output; // return place in scope 0 at test.rs:5:72: 5:81
    let mut _3: std::boxed::Box&lt;F&gt;;      // in scope 0 at test.rs:6:19: 6:24
    let mut _4: A;                       // in scope 0 at test.rs:6:26: 6:30

    bb0: {
        StorageLive(_3);                 // bb0[0]: scope 0 at test.rs:6:19: 6:24
        _3 = move _1;                    // bb0[1]: scope 0 at test.rs:6:19: 6:24
        StorageLive(_4);                 // bb0[2]: scope 0 at test.rs:6:26: 6:30
        _4 = move _2;                    // bb0[3]: scope 0 at test.rs:6:26: 6:30
        _0 = const &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::call_once(move (*_3), move _4) -&gt; [return: bb2, unwind: bb6]; // bb0[4]: scope 0 at test.rs:6:5: 6:31
                                         // ty::Const
                                         // + ty: extern &quot;rust-call&quot; fn(F, A) -&gt; &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::Output {&lt;F as std::ops::FnOnce&lt;A&gt;&gt;::call_once}
                                         // + val: Value(Scalar(&lt;ZST&gt;))
                                         // mir::Constant
                                         // + span: test.rs:6:5: 6:17
                                         // + user_ty: UserType(0)
                                         // + literal: Const { ty: extern &quot;rust-call&quot; fn(F, A) -&gt; &lt;F as std::ops::FnOnce&lt;A&gt;&gt;::Output {&lt;F as std::ops::FnOnce&lt;A&gt;&gt;::call_once}, val: Value(Scalar(&lt;ZST&gt;)) }
    }

    bb1 (cleanup): {
        resume;                          // bb1[0]: scope 0 at test.rs:5:1: 7:2
    }

    bb2: {
        StorageDead(_4);                 // bb2[0]: scope 0 at test.rs:6:30: 6:31
        drop(_3) -&gt; [return: bb7, unwind: bb4]; // bb2[1]: scope 0 at test.rs:6:30: 6:31
    }

    bb3 (cleanup): {
        drop(_1) -&gt; bb1;                 // bb3[0]: scope 0 at test.rs:7:1: 7:2
    }

    bb4 (cleanup): {
        drop(_2) -&gt; bb3;                 // bb4[0]: scope 0 at test.rs:7:1: 7:2
    }

    bb5 (cleanup): {
        drop(_3) -&gt; bb4;                 // bb5[0]: scope 0 at test.rs:6:30: 6:31
    }

    bb6 (cleanup): {
        drop(_4) -&gt; bb5;                 // bb6[0]: scope 0 at test.rs:6:30: 6:31
    }

    bb7: {
        StorageDead(_3);                 // bb7[0]: scope 0 at test.rs:6:30: 6:31
        drop(_2) -&gt; [return: bb8, unwind: bb3]; // bb7[1]: scope 0 at test.rs:7:1: 7:2
    }

    bb8: {
        drop(_1) -&gt; [return: bb9, unwind: bb1]; // bb8[0]: scope 0 at test.rs:7:1: 7:2
    }

    bb9: {
        goto -&gt; bb10;                    // bb9[0]: scope 0 at test.rs:7:2: 7:2
    }

    bb10: {
        return;                          // bb10[0]: scope 0 at test.rs:7:2: 7:2
    }
}
</pre></div>



<a name="194376350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194376350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194376350">(Apr 16 2020 at 22:34)</a>:</h4>
<p>mir looks good</p>



<a name="194376361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194376361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194376361">(Apr 16 2020 at 22:34)</a>:</h4>
<p>test doesn't pass</p>



<a name="194376394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194376394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194376394">(Apr 16 2020 at 22:35)</a>:</h4>
<p>there might still be dynamic allocas</p>



<a name="194376402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194376402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194376402">(Apr 16 2020 at 22:35)</a>:</h4>
<p>from another source</p>



<a name="194376426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194376426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194376426">(Apr 16 2020 at 22:35)</a>:</h4>
<p>hmmm</p>



<a name="194383564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194383564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194383564">(Apr 17 2020 at 00:19)</a>:</h4>
<p>actually it works :)</p>



<a name="194383581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194383581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194383581">(Apr 17 2020 at 00:19)</a>:</h4>
<p>I was testing too fast, come back and realized about --keep-stage 1</p>



<a name="194383610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194383610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194383610">(Apr 17 2020 at 00:20)</a>:</h4>
<p>anyway, other tests are failing need to check, will do tomorrow</p>



<a name="194383722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194383722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194383722">(Apr 17 2020 at 00:21)</a>:</h4>
<div class="codehilite"><pre><span></span>2020-04-16T23:56:26.6116980Z error[E0382]: use of moved value: `y`
2020-04-16T23:56:26.6117524Z   --&gt; /checkout/src/test/ui/unsized-locals/double-move.rs:20:22
2020-04-16T23:56:26.6117775Z    |
2020-04-16T23:56:26.6117967Z LL |         let y = *x;
2020-04-16T23:56:26.6118550Z    |             - move occurs because `y` has type `str`, which does not implement the `Copy` trait
2020-04-16T23:56:26.6118897Z LL |         drop_unsized(y);
2020-04-16T23:56:26.6119577Z    |                      - value moved here
2020-04-16T23:56:26.6119881Z LL |         drop_unsized(y); //~ERROR use of moved value
2020-04-16T23:56:26.6120194Z    |                      ^ value used here after move
2020-04-16T23:56:26.6120614Z error[E0382]: use of moved value: `x`
</pre></div>



<a name="194383723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194383723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194383723">(Apr 17 2020 at 00:21)</a>:</h4>
<p>:)</p>



<a name="194383724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194383724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194383724">(Apr 17 2020 at 00:21)</a>:</h4>
<p>will see tomorrow</p>



<a name="194387169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387169">(Apr 17 2020 at 01:24)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="c1">// Check that while a trait with by-value self is object-safe, we</span>
<span class="c1">// can&#39;t actually invoke it from an object (yet...?).</span>

<span class="cp">#![feature(rustc_attrs)]</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">Bar</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">bar</span><span class="p">(</span><span class="bp">self</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">Baz</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">baz</span><span class="p">(</span><span class="bp">self</span>: <span class="nc">Self</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">use_bar</span><span class="p">(</span><span class="n">t</span>: <span class="nb">Box</span><span class="o">&lt;</span><span class="n">dyn</span><span class="w"> </span><span class="n">Bar</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">t</span><span class="p">.</span><span class="n">bar</span><span class="p">()</span><span class="w"> </span><span class="c1">//~ ERROR cannot move a value of type dyn Bar</span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="194387171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387171">(Apr 17 2020 at 01:25)</a>:</h4>
<p>this now compiles</p>



<a name="194387182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387182">(Apr 17 2020 at 01:25)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> <span aria-label="point up" class="emoji emoji-1f446" role="img" title="point up">:point_up:</span></p>



<a name="194387351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387351">(Apr 17 2020 at 01:28)</a>:</h4>
<p>maybe you need to check for the <code>unsized_locals</code> feature-gate?</p>



<a name="194387360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387360">(Apr 17 2020 at 01:29)</a>:</h4>
<p>in your special-casing</p>



<a name="194387661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387661">(Apr 17 2020 at 01:34)</a>:</h4>
<p>I meant, this is an existing test that was supposed to fail</p>



<a name="194387663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387663">(Apr 17 2020 at 01:34)</a>:</h4>
<p>but now compiles</p>



<a name="194387665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387665">(Apr 17 2020 at 01:34)</a>:</h4>
<p>unsure what you meant</p>



<a name="194387692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387692">(Apr 17 2020 at 01:35)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> your code needs to only go into effect if <code>#![feature(unsized_locals)]</code> was specified</p>



<a name="194387704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387704">(Apr 17 2020 at 01:35)</a>:</h4>
<p>ahhh</p>



<a name="194387710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387710">(Apr 17 2020 at 01:35)</a>:</h4>
<p>otherwise you're removing an unsized move that would've prevented the code compiling w/o feature-gates</p>



<a name="194387714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387714">(Apr 17 2020 at 01:35)</a>:</h4>
<p>with no opt-in</p>



<a name="194387760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387760">(Apr 17 2020 at 01:36)</a>:</h4>
<p>(we probably want a separate feature-gate for but testing you can use <code>unsized_locals</code>)</p>



<a name="194387765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387765">(Apr 17 2020 at 01:36)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="194387767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387767">(Apr 17 2020 at 01:36)</a>:</h4>
<p>will fix tomorrow</p>



<a name="194387776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387776">(Apr 17 2020 at 01:36)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> <span class="user-mention" data-user-id="116009">@nikomatsakis</span> would be really nice if we don't have to change <code>typeck</code> and it looks like we won't :D</p>



<a name="194387789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387789">(Apr 17 2020 at 01:37)</a>:</h4>
<p>(basically we want all of core/alloc/std to compile w/o <code>#![feature(unsized_locals)]</code> and at most a new feature-gate)</p>



<a name="194387794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387794">(Apr 17 2020 at 01:37)</a>:</h4>
<p>(to make sure we're not miscompiling anyone's dynamic alignments)</p>



<a name="194387800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194387800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194387800">(Apr 17 2020 at 01:37)</a>:</h4>
<p>(via public stdlib APIs, and even worse, stable ones)</p>



<a name="194435982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194435982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194435982">(Apr 17 2020 at 13:02)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span class="user-mention" data-user-id="119009">@eddyb</span> <a href="https://github.com/rust-lang/rust/issues/71170" title="https://github.com/rust-lang/rust/issues/71170">#71170</a> is now ready for review, there are some little stderr files under <code>unsized_locals</code> feature flag that have changed slightly as I guess you were expecting</p>



<a name="194436051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194436051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194436051">(Apr 17 2020 at 13:02)</a>:</h4>
<p><del>we accidentally used the wrong topic lmao lemme fix that</del> done</p>



<a name="194510765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194510765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194510765">(Apr 17 2020 at 23:08)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> we were discussing with <span class="user-mention" data-user-id="116009">@nikomatsakis</span> about this issue after his reviews</p>



<a name="194510780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194510780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194510780">(Apr 17 2020 at 23:09)</a>:</h4>
<p>Niko told me to use the recursion and you kind of advised against it</p>



<a name="194510789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194510789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194510789">(Apr 17 2020 at 23:09)</a>:</h4>
<p>I've done with recursion and it doesn't work</p>



<a name="194510804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194510804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194510804">(Apr 17 2020 at 23:09)</a>:</h4>
<p>all I can see is that ty is getting from an inner expr</p>



<a name="194510827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194510827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194510827">(Apr 17 2020 at 23:09)</a>:</h4>
<p>but the errors I'm getting seems to suggest that the Scope is doing something wrong</p>



<a name="194510886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194510886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194510886">(Apr 17 2020 at 23:10)</a>:</h4>
<div class="codehilite"><pre><span></span>error[E0382]: use of moved value
    --&gt; src/libcore/iter/traits/iterator.rs:2534:25
     |
2534 |             move |x, y| cmp::max_by(x, y, &amp;mut compare)
     |                         ^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^^
     |                         |           |
     |                         |           value moved here
     |                         |           move occurs because value has type T, which does not implement the Copy trait
     |                         value used here after move
     |
help: consider restricting type parameter T
</pre></div>



<a name="194515561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194515561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194515561">(Apr 18 2020 at 00:15)</a>:</h4>
<p>uhhhhhh</p>



<a name="194515566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194515566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194515566">(Apr 18 2020 at 00:15)</a>:</h4>
<p>that doesn't pass any arguments by dereference</p>



<a name="194515604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194515604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194515604">(Apr 18 2020 at 00:16)</a>:</h4>
<p>which means no code should run different than today</p>



<a name="194515615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194515615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194515615">(Apr 18 2020 at 00:16)</a>:</h4>
<p>this is why I was suggesting you might <em>peek</em> behind the <code>Scope</code> to see if it is an unsized <code>Deref</code></p>



<a name="194515619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194515619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194515619">(Apr 18 2020 at 00:16)</a>:</h4>
<p>so that you don't do anything if it's not</p>



<a name="194515636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194515636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194515636">(Apr 18 2020 at 00:16)</a>:</h4>
<p>basically you can do the recursion thing but <em>only</em> after you confirm that it needs the special case</p>



<a name="194585479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194585479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194585479">(Apr 19 2020 at 08:12)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> so after your PR, there'll be no <code>alloca</code> for code that is still permitted, right? is that checked/ensured by codegen?</p>



<a name="194598052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194598052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194598052">(Apr 19 2020 at 13:36)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> what did you mean exactly by code that is still permitted?</p>



<a name="194598059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194598059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194598059">(Apr 19 2020 at 13:36)</a>:</h4>
<p>and by checked/ensured by codegen you meant if we had some kind of test case or what?</p>



<a name="194598448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194598448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194598448">(Apr 19 2020 at 13:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116266">Santiago Pastorino</span> <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/194598052" title="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/194598052">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> what did you mean exactly by code that is still permitted?</p>
</blockquote>
<p>I was under the impression that not all unsized-local code can fit the pattern that is used to fix the soundness bug?</p>



<a name="194598453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Box%3Cdyn%20FnOnce%3E%20doesn%27t%20respect%20self%20alignment%20%2368304/near/194598453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn&#x27;t.20respect.20self.20alignment.20.2368304.html#194598453">(Apr 19 2020 at 13:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116266">Santiago Pastorino</span> <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/194598059" title="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Box.3Cdyn.20FnOnce.3E.20doesn't.20respect.20self.20alignment.20.2368304/near/194598059">said</a>:</p>
<blockquote>
<p>and by checked/ensured by codegen you meant if we had some kind of test case or what?</p>
</blockquote>
<p>more like, ICE in codegen at the place where we used to emit an <code>alloca</code></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>